package mya.mes.mdc.local.json;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;

import java.io.IOException;

public abstract class AbstractJsonSerializer<T> extends JsonSerializer<T> {


    protected void out(JsonGenerator gen, String field, String value) throws IOException {
        if (value == null) {
            return;
        }

        gen.writeStringField(field, value);
    }

    protected void out(JsonGenerator gen, String field, Integer value) throws IOException {
        if (value == null) {
            return;
        }

        gen.writeNumberField(field, value);
    }


    protected void out(JsonGenerator gen, String field, Long value) throws IOException {
        if (value == null) {
            return;
        }

        gen.writeNumberField(field, value);
    }

    protected void out(JsonGenerator gen, String field, Boolean value) throws IOException {
        if (value == null) {
            return;
        }

        gen.writeBooleanField(field, value);
    }
}
